<script type="text/javascript">
		Yutil.useLoadingMessage();
		Yutil.en.enhance();
</script>
<%
	String entId = request.getParameter("enterpriseId");
	//System.out.println("entId = " + entId);
	Set employees = new HashSet();
	List tmp;
	if (("-1").equals(entId)) {
		tmp = EmployeeService.$.getAllEmployee();
		for (Iterator itr = tmp.iterator(); itr.hasNext();) {
			employees.add(itr.next());
		}
	} else {
		Enterprise ent = EnterpriseService.$.getEnterpriseById(Integer
				.parseInt(entId));
		employees = ent.getEmployees();
		for (Iterator it = employees.iterator(); it.hasNext();) {
			Employee e2 = (Employee) it.next();
		}
	}
	UIutil $ = UIutil.$;
%>

<fieldset>
	<legend>
		员工列表
	</legend>
	<table align="left" border="0px">
		<thead>
			<tr>
				<th>
					<input id="selectAll" type="checkbox" onclick="checkAll(this)"></input>
					全选
				</th>
				<th>
					员工编号
				</th>
				<th>
					姓名
				</th>
				<th>
					性别
				</th>
				<th>
					联系电话
				</th>
				<th>
					地址
				</th>
			</tr>
		</thead>
		<tbody>
			<%
				if (employees.size() <= 0) {
			%>
			<tr>
				<td>
					无记录
				</td>
			</tr>
			<%
				} else {
					for (Iterator it = employees.iterator(); it.hasNext();) {
						Employee e = (Employee) it.next();
			%>
			<tr>
				<td>
					<input type="checkbox" name="checkbox"
						employee="<%=e.getEmployeeId()%>" value="<%=e.getEmployeeId()%>"
						onclick="isChecked(this)" />
				</td>
				<td>
					E<%=e.getEmployeeId()%></td>
				<td>
					<a href="javascript:;" onclick="toEmployeeDetail(this)"
						value="<%=e.getEmployeeId()%>"><%=e.getName()%></a>
				</td>
				<td><%=e.getSex()%></td>
				<td><%=e.getPhone()%></td>
				<td><%=e.getAddress()%></td>
			</tr>
			<%
				}
				}
			%>

		</tbody>
	</table>
</fieldset>

<script type="text/javascript">
	checkAll = function(oElem) {
		var checked = oElem.checked;
		var checkboxes = document.getElementsByName("checkbox");
		for(var i=0;i<checkboxes.length;i++) {
			var checkb = checkboxes[i];
			if(checkb.getAttribute('employee')) {
				checkb.checked = checked;
				}
			}
		}
	
	isChecked = function(thisCB) {
		var checkbox = thisCB;
		if(checkbox.checked == false)
		$('selectAll').checked = false;
	}
	
	toEmployeeDetail = function(oElem) {
			Yutil.createDialog('employeeDialog', '80%', '80%', '详细信息');
			var aLink = oElem;
			var userid = aLink.getAttribute('value');
			var url = 'la_employee_details.jsp';
			var pars = "employeeId=" + userid;
			var myAjax = new Ajax.Updater('employeeDialog_content', url, {method:'get', parameters:pars, evalScripts: true});
			Yutil.showDialog('employeeDialog');
		}
	
	
</script>

<%@ page import="com.esms.struts.service.JspWidget"%>
<%@ page import="java.util.*"%>
<%@ page import="com.esms.bean.*"%>
<%@ page import="com.esms.struts.service.*"%>
<%@ page language="java" contentType="text/html; charset=utf-8"%>